import pytest
import requests
from deepdiff import DeepDiff


class Testcase:
    expect = {
        "slideshow": {
            "author": "Yours Truly",
            "date": "date of publication"
        },
        'slides': [{
            "title": "wake up to wonderwidgets!",
            'type': 'a1l'},
            {
                "items': ['why <em>Wonderwidgets</em> are great', 'who<em>buys</em> wonderwidgets']，"
                "title": "overview",
                "type": 'all'
            }],
        "title": "sample slide show"
    }

    def setup(self):
        # 返回字典格式报文
        self.response = requests.get('http://www.httpbin.org/json').json()
        print(self.response)

    def test_case_01(self):
        print("用例对比结果:")
        print(DeepDiff(self.response, self.expect))

    def test_case_02(self):
        print("用例对比结果:")
        print(DeepDiff(self.response['slideshow']['author'], 'Yours Truly1'))
        print("用例对比结果:")
        print(DeepDiff(self.response, self.expect, view='tree', ignore_order=True,
                       ignore_string_case=True, exclude_paths={"root['slideshow']['data']"}
                       ))

if __name__ == '__main__':
    pytest.main(['-s'])
